home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / misc_pto / bcolor20 / clredit.m < prev    next >
Text File  |  1988-12-17  |  15KB  |  631 lines

  1. ;************************************************************************
  2. ;**                  for   B R I E F   ver. 2.1                         *
  3. ;**                                                                     *
  4. ;**   Clredit Macro - Create, change and delete colors in color.mnu     *
  5. ;**                                                                     *
  6. ;**         By Tom Bentley     December 1988     Ver. 2.0               *
  7. ;**                                                                     *
  8. ;**                 (C) Copyright - All rights reserved                 *
  9. ;**                                                                     *
  10. ;************************************************************************
  11.  
  12. (extern    clr_buf_mnu clr_flag clr_buf_mnu clr_last_mnu)
  13.  
  14. (macro clredit
  15.    (
  16.       (int     curr_buff)
  17.  
  18.       (= curr_buff (inq_buffer))
  19.       (create_window 28 19 53 3 "(Edit,Del,Move Esc)")
  20.       (set_buffer clr_buf_mnu)
  21.       (attach_buffer clr_buf_mnu)
  22.       (keyboard_push)
  23.       (assign_to_key "<Down-Arrow>" "menu_down")
  24.       (assign_to_key "<Up-Arrow>" "menu_up")
  25.       (assign_to_key "<Enter>" "clr_edit")
  26.       (assign_to_key "E" "clr_edit")
  27.       (assign_to_key "e" "clr_edit")
  28.       (assign_to_key "d" "clr_del 0")
  29.       (assign_to_key "D" "clr_del 0")
  30.       (assign_to_key "m" "clr_move")
  31.       (assign_to_key "M" "clr_move")
  32.       (assign_to_key "<Esc>" "exit")
  33.       (goto_line 1)
  34.       (drop_anchor 3)
  35.       (refresh)
  36.       (process)
  37.       (keyboard_pop)
  38.       (raise_anchor)
  39.       (set_buffer curr_buff)
  40.       (delete_window)
  41.       (message " ")
  42.       (set_buffer clr_buf_mnu)
  43.       (if (inq_modified)
  44.          (
  45.             (write_buffer)
  46.          )
  47.       )
  48.       (= clr_last_mnu 1)
  49.       (= clr_flag 0)
  50.       (while (== 0 clr_flag)
  51.          (
  52.             (goto_line clr_last_mnu)
  53.             (if (! (inq_position clr_last_mnu))
  54.                (++ clr_last_mnu)
  55.             ;else
  56.                (= clr_flag 1)
  57.             )
  58.          )
  59.       )
  60.       (set_buffer curr_buff)
  61.    )
  62. )
  63.  
  64. (macro menu_up
  65.    (
  66.       (if (! (up))
  67.          (
  68.             (return 0)
  69.          )
  70.       ;else
  71.          (
  72.             (raise_anchor)
  73.             (drop_anchor 3)
  74.             (return 1)
  75.          )
  76.       )
  77.    )
  78. )
  79.  
  80. (macro menu_down
  81.    (
  82.       (down)
  83.       (if (inq_position)
  84.          (
  85.             (up)
  86.             (return 0)
  87.          )
  88.       ;else
  89.          (
  90.             (raise_anchor)
  91.             (drop_anchor 3)
  92.             (return 1)
  93.          )
  94.       )
  95.    )
  96. )
  97.  
  98. (macro clr_move
  99.    (
  100.  
  101.       (string  clr_line)
  102.  
  103.       (= clr_line (trim (read)))
  104.       (= clr_flag 0)
  105.       (clr_del 1)
  106.       (refresh)
  107.       (error "Move Color: Up/Down-Insert,Append (I,A)")
  108.       (keyboard_push)
  109.       (assign_to_key "<Down-Arrow>" "menu_down")
  110.       (assign_to_key "<Up-Arrow>" "menu_up")
  111.       (assign_to_key "a" "clr_move_upd 1")
  112.       (assign_to_key "A" "clr_move_upd 1")
  113.       (assign_to_key "i" "clr_move_upd 2")
  114.       (assign_to_key "I" "clr_move_upd 2")
  115.       (process)
  116.       (if (== clr_flag 2)
  117.          (
  118.             (insert "\n")
  119.             (up)
  120.             (beginning_of_line)
  121.          )
  122.       ;else
  123.          (
  124.             (end_of_line)
  125.             (insert "\n")
  126.          )
  127.       )
  128.       (insert clr_line)
  129.       (raise_anchor)
  130.       (beginning_of_line)
  131.       (drop_anchor 3)
  132.       (keyboard_pop)
  133.       (message "Color Moved...")
  134.    )
  135. )
  136.  
  137. (macro clr_move_upd
  138.    (
  139.       (get_parm 0 clr_flag)
  140.       (exit)
  141.    )
  142. )
  143.  
  144. (macro clr_del
  145.    (
  146.       (int     clr_del_parm)
  147.  
  148.       (get_parm 0 clr_del_parm)
  149.       (if (== clr_del_parm 0)
  150.          (
  151.             (if (! (up))
  152.                (
  153.                   (error "Cannot delete default color")
  154.                   (beep)
  155.                   (return 0)
  156.                )
  157.             ;else
  158.                (
  159.                   (down)
  160.                )
  161.             )
  162.          )
  163.       )
  164.       (delete_line)
  165.       (if (inq_position)
  166.          (
  167.             (up)
  168.             (raise_anchor)
  169.             (drop_anchor 3)
  170.          )
  171.       )
  172.       (message "Color deleted...")
  173.    )
  174. )
  175.  
  176. (macro clr_edit
  177.    (
  178.       (int      clr_edit_buf)
  179.       (int      clr_bg clr_nt clr_st clr_nm clr_em clr_bw clr_last_bg)
  180.       (int      clr_sv_bg clr_sv_nt clr_sv_st clr_sv_nm clr_sv_em clr_sv_bw)
  181.  
  182.       (string   clr_string clr_desc_str)
  183.  
  184.       (global   clr_bg clr_nt clr_st clr_nm clr_em clr_bw clr_last_bg)
  185.  
  186.       (= clr_flag 0)
  187.       (= clr_string (compress (read)))
  188.       (= clr_desc_str (substr clr_string 1 (- (index clr_string ";") 1)))
  189.       (search_fwd ";color")
  190.       (next_char 7)
  191.       (= clr_bg (atoi (read 1)))
  192.       (next_char 2)
  193.       (= clr_nt (atoi (read 2)))
  194.       (next_char 3)
  195.       (= clr_st (atoi (read 2)))
  196.       (next_char 3)
  197.       (= clr_nm (atoi (read 2)))
  198.       (next_char 3)
  199.       (= clr_em (atoi (read 2)))
  200.       (next_char 3)
  201.       (= clr_bw (atoi (read 1)))
  202.       (= clr_sv_bg clr_bg)
  203.       (= clr_sv_nt clr_nt)
  204.       (= clr_sv_st clr_st)
  205.       (= clr_sv_nm clr_nm)
  206.       (= clr_sv_em clr_em)
  207.       (= clr_sv_bw clr_bw)
  208.       (beginning_of_line)
  209.       (= clr_edit_buf (create_buffer "EDIT COLORS" NULL 1))
  210.       (set_buffer clr_edit_buf)
  211.       (top_of_buffer)
  212.       (insert "     Background    =")
  213.       (sprintf clr_string "%2d" clr_bg)
  214.       (insert clr_string)
  215.       (insert ";1\n")
  216.       (insert "    Normal  Text   =")
  217.       (sprintf clr_string "%2d" clr_nt)
  218.       (insert clr_string)
  219.       (insert ";2\n")
  220.       (insert "   Selected Title  =")
  221.       (sprintf clr_string "%2d" clr_st)
  222.       (insert clr_string)
  223.       (insert ";3\n")
  224.       (insert "   Normal Message  =")
  225.       (sprintf clr_string "%2d" clr_nm)
  226.       (insert clr_string)
  227.       (insert ";4\n")
  228.       (insert "   Error  Message  =")
  229.       (sprintf clr_string "%2d" clr_em)
  230.       (insert clr_string)
  231.       (insert ";5\n")
  232.       (insert " Borderless Window =")
  233.       (sprintf clr_string "%d" clr_bw)
  234.       (insert clr_string)
  235.       (insert ";6\n")
  236.       (insert "    Description    =")
  237.       (insert clr_desc_str)
  238.       (insert ";7")
  239.       (goto_line 1)
  240.       (drop_anchor 3)
  241.       (color_it)
  242.       (create_window 3 19 22 11 "F10 to Set")
  243.       (attach_buffer clr_edit_buf)
  244.       (refresh)
  245.       (keyboard_push)
  246.       (assign_to_key "<Down-Arrow>" "sel_down")
  247.       (assign_to_key "<Up-Arrow>" "sel_up")
  248.       (assign_to_key "<Left-Arrow>" "clr_left_right 0")
  249.       (assign_to_key "<Right-Arrow>" "clr_left_right 1")
  250.       (assign_to_key "<Enter>" "clr_desc")
  251.       (assign_to_key "<F10>" "clr_done")
  252.       (assign_to_key "<Esc>" "clr_esc")
  253.       (disp_color_msg)
  254.       (process)
  255.       (goto_line 7)
  256.       (= clr_string (compress (read)))
  257.       (= clr_desc_str (substr clr_string (+ (index clr_string "=") 1)
  258.             (- (index clr_string ";") (+ (index clr_string "=") 1))))
  259.       (keyboard_pop)
  260.       (raise_anchor)
  261.       (color clr_sv_bg clr_sv_nt clr_sv_st clr_sv_nm clr_sv_em)
  262.       (delete_window)
  263.       (delete_buffer clr_edit_buf)
  264.       (set_buffer clr_buf_mnu)
  265.       (if (== clr_flag 1)
  266.          (clr_update clr_desc_str)
  267.       )
  268.    )
  269. )
  270.  
  271. (macro sel_down
  272.    (
  273.       (if (menu_down)
  274.          (
  275.             (color_it)
  276.             (disp_color_msg)
  277.          )
  278.       )
  279.    )
  280. )
  281.  
  282. (macro sel_up
  283.    (
  284.       (if (menu_up)
  285.          (
  286.             (color_it)
  287.             (disp_color_msg)
  288.          )
  289.       )
  290.    )
  291. )
  292.  
  293. (macro clr_left_right
  294.    (
  295.  
  296.       (int     clr_l_r clr_line)
  297.  
  298.       (get_parm 0 clr_l_r)
  299.       (search_fwd ";")
  300.       (right)
  301.       (= clr_line (atoi (read 1)))
  302.       (if (== clr_line 7)
  303.          (
  304.             (beginning_of_line)
  305.             (error "Use Enter key to change Description...")
  306.             (beep)
  307.             (return 0)
  308.          )
  309.       )
  310.       (beginning_of_line)
  311.       (if (== clr_l_r 0)
  312.          (
  313.             (clr_left clr_line)
  314.          )
  315.       ;else
  316.          (
  317.             (clr_right clr_line)
  318.          )
  319.       )
  320.       (color_it)
  321.       (disp_color_msg)
  322.    )
  323. )
  324.  
  325. (macro clr_left
  326.    (
  327.       (int     clr_line)
  328.       (string  new_clr)
  329.  
  330.       (get_parm 0 clr_line)
  331.       (switch clr_line
  332.         1
  333.          (
  334.             (if (> clr_bg 0)
  335.                (-- clr_bg)
  336.             ;else
  337.                (= clr_bg 7)
  338.             )
  339.             (sprintf new_clr "=%1d;" clr_bg)
  340.          )
  341.         2
  342.          (
  343.             (if (> clr_nt 0)
  344.                (-- clr_nt)
  345.             ;else
  346.                (= clr_nt 15)
  347.             )
  348.             (sprintf new_clr "=%2d;" clr_nt)
  349.          )
  350.         3
  351.          (
  352.             (if (> clr_st 0)
  353.                (-- clr_st)
  354.             ;else
  355.                (= clr_st 15)
  356.             )
  357.             (sprintf new_clr "=%2d;" clr_st)
  358.          )
  359.         4
  360.          (
  361.             (if (> clr_nm 0)
  362.                (-- clr_nm)
  363.             ;else
  364.                (= clr_nm 15)
  365.             )
  366.             (sprintf new_clr "=%2d;" clr_nm)
  367.          )
  368.         5
  369.          (
  370.             (if (> clr_em 0)
  371.                (-- clr_em)
  372.             ;else
  373.                (= clr_em 15)
  374.             )
  375.             (sprintf new_clr "=%2d;" clr_em)
  376.          )
  377.         6
  378.          (
  379.             (if (> clr_bw 0)
  380.                (-- clr_bw)
  381.             ;else
  382.                (= clr_bw 7)
  383.             )
  384.             (sprintf new_clr "=%1d;" clr_bw)
  385.          )
  386.       )
  387.       (translate "=*;" new_clr 0) 
  388.    )
  389. )
  390.  
  391. (macro clr_right
  392.    (
  393.       (int     clr_line)
  394.       (string  new_clr)
  395.  
  396.       (get_parm 0 clr_line)
  397.       (switch clr_line
  398.         1
  399.          (
  400.             (if (< clr_bg 7)
  401.                (++ clr_bg)
  402.             ;else
  403.                (= clr_bg 0)
  404.             )
  405.             (sprintf new_clr "=%1d;" clr_bg)
  406.          )
  407.         2
  408.          (
  409.             (if (< clr_nt 15)
  410.                (++ clr_nt)
  411.             ;else
  412.                (= clr_nt 0)
  413.             )
  414.             (sprintf new_clr "=%2d;" clr_nt)
  415.          )
  416.         3
  417.          (
  418.             (if (< clr_st 15)
  419.                (++ clr_st)
  420.             ;else
  421.                (= clr_st 0)
  422.             )
  423.             (sprintf new_clr "=%2d;" clr_st)
  424.          )
  425.         4
  426.          (
  427.             (if (< clr_nm 15)
  428.                (++ clr_nm)
  429.             ;else
  430.                (= clr_nm 0)
  431.             )
  432.             (sprintf new_clr "=%2d;" clr_nm)
  433.          )
  434.         5
  435.          (
  436.             (if (< clr_em 15)
  437.                (++ clr_em)
  438.             ;else
  439.                (= clr_em 0)
  440.             )
  441.             (sprintf new_clr "=%2d;" clr_em)
  442.          )
  443.         6
  444.          (
  445.             (if (< clr_bw 7)
  446.                (++ clr_bw)
  447.             ;else
  448.                (= clr_bw 0)
  449.             )
  450.             (sprintf new_clr "=%1d;" clr_bw)
  451.          )
  452.       )
  453.       (translate "=*;" new_clr 0) 
  454.    )
  455. )
  456.  
  457. (macro clr_desc
  458.    (
  459.       (string  get_desc clr_read trans_string)
  460.  
  461.       (= clr_read (compress (read)))
  462.       (search_fwd ";")
  463.       (right)
  464.       (if (!= (atoi (read 1)) 7)
  465.          (
  466.             (beginning_of_line)
  467.             (beep)
  468.             (error "Enter valid for Description only (F10 to Set)")
  469.             (return 0)
  470.          )
  471.       )
  472.       (beginning_of_line)
  473.       (get_parm NULL get_desc "Enter Description : " 24 
  474.          (substr clr_read (+ (index clr_read "=") 1)
  475.             (- (index clr_read ";") (+ (index clr_read "=") 1))))
  476.       (if (search_string ";" get_desc)
  477.          (
  478.             (error "Invalid character (;) in description...")
  479.             (return 0)
  480.          )
  481.       )
  482.       (sprintf trans_string "=%s;" get_desc)
  483.       (translate "=*;" trans_string 0) 
  484.       (disp_color_msg)
  485.    )
  486. )
  487.  
  488. (macro clr_done
  489.    (
  490.       (int     error_flag)
  491.  
  492.       (= error_flag 0)
  493.  
  494.       (if (|| (== clr_bg clr_nt) (== clr_bg clr_st))
  495.          (= error_flag 1)
  496.       )
  497.       (if (|| (== clr_bg clr_nm) (== clr_bg clr_em))
  498.          (= error_flag 1)
  499.       )
  500.       (if (|| (== clr_bw clr_nt) (== clr_bw clr_st))
  501.          (= error_flag 1)
  502.       )
  503.       (if (|| (== clr_bw clr_nm) (== clr_bw clr_em))
  504.          (= error_flag 1)
  505.       )
  506.       (if (== error_flag 1)
  507.          (
  508.             (error "COLOR ERROR - A text color = a background color")
  509.             (return 0)
  510.          )
  511.       )
  512.       (message " ")
  513.       (= clr_flag 1)
  514.       (exit)
  515.    )
  516. )
  517.  
  518. (macro clr_esc
  519.    (
  520.       (message " ")
  521.       (exit)
  522.    )
  523. )
  524.  
  525. (macro color_it
  526.    (
  527.       (int     clr_line)
  528.  
  529.       (search_fwd ";")
  530.       (right)
  531.       (= clr_line (atoi (read 1)))
  532.       (beginning_of_line)
  533.       (if (|| (== clr_line 1) (== clr_line 7))
  534.          (= clr_last_bg clr_bg)
  535.       ;else
  536.          (if (== clr_line 6)
  537.             (= clr_last_bg clr_bw)
  538.          )
  539.       )
  540.       (color clr_last_bg clr_nt clr_st clr_nm clr_em)
  541.    )
  542. )
  543.  
  544. (macro disp_color_msg
  545.    (
  546.       (string  clr_read)
  547.  
  548.       (= clr_read (compress (read)))
  549.       (search_fwd ";")
  550.       (right)
  551.       (if (== (atoi (read 1)) 5)
  552.          (
  553.             (error "%s" (substr clr_read 1 (- (index clr_read ";") 1)))
  554.          )
  555.       ;else
  556.          (
  557.             (message "%s" (substr clr_read 1 (- (index clr_read ";") 1)))
  558.          )
  559.       )
  560.       (beginning_of_line)
  561.    )
  562. )
  563.  
  564. (macro clr_update
  565.    (
  566.       (int     clr_ins_mode)
  567.       (string  clr_desc_str work_str)
  568.  
  569.       (refresh)
  570.       (keyboard_push)
  571.       (beginning_of_line)
  572.       (get_parm 0 clr_desc_str)
  573.       (error "New Color: Up/Down - Chg,Ins,Append (C,I,A)")
  574.       (assign_to_key "<Down-Arrow>" "menu_down")
  575.       (assign_to_key "<Up-Arrow>" "menu_up")
  576.       (assign_to_key "c" "clr_upd 0")
  577.       (assign_to_key "C" "clr_upd 0")
  578.       (assign_to_key "a" "clr_upd 1")
  579.       (assign_to_key "A" "clr_upd 1")
  580.       (assign_to_key "i" "clr_upd 2")
  581.       (assign_to_key "I" "clr_upd 2")
  582.       (process)
  583.       (raise_anchor)
  584.       (= clr_ins_mode (insert_mode 1))
  585.       (if (== clr_flag 0)
  586.          (
  587.             (= clr_flag 2)
  588.             (delete_line)
  589.          )
  590.       )
  591.       (if (== clr_flag 2)
  592.          (
  593.             (insert "\n")
  594.             (up)
  595.             (beginning_of_line)
  596.          )
  597.       ;else
  598.          (
  599.             (end_of_line)
  600.             (insert "\n")
  601.          )
  602.       )
  603.       (sprintf work_str "%-24s;color " clr_desc_str)
  604.       (insert work_str)
  605.       (sprintf work_str "%1d " clr_bg)
  606.       (insert work_str)
  607.       (sprintf work_str "%2d " clr_nt)
  608.       (insert work_str)
  609.       (sprintf work_str "%2d " clr_st)
  610.       (insert work_str)
  611.       (sprintf work_str "%2d " clr_nm)
  612.       (insert work_str)
  613.       (sprintf work_str "%2d;" clr_em)
  614.       (insert work_str)
  615.       (sprintf work_str "%1d " clr_bw)
  616.       (insert work_str)
  617.       (insert_mode clr_ins_mode)
  618.       (beginning_of_line)
  619.       (drop_anchor 3)
  620.       (keyboard_pop)
  621.       (message " ")
  622.    )
  623. )
  624.  
  625. (macro clr_upd
  626.    (
  627.       (get_parm 0 clr_flag)
  628.       (exit)
  629.    )
  630. )
  631.